package tsb.trinhnx.example;

public class Square extends BinaryExpression {

	private Numeral degree;
	private Expression base;

	/**
	 * Default degree is 2
	 * @param base
	 */
	public Square(Expression base) {
		this.base = base;
		degree = new Numeral(2);
	}

	@Override
	public int evaluate() {
		int value = this.base.evaluate();
		// TODO: overflow max_int may be.
		// Haizzzz
		return value * value;
	}

	@Override
	public String toString() {
		return this.base.toString() + "^" + this.degree.toString();

	}
}
